package com.project.config;

import com.project.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/emFace/**").addResourceLocations("file:E:\\ManagementSystem\\src\\faceImg/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/user/getLoginUser");

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/stu/findAll");

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/room/findAll");

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/user/findAll");

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/class/findAll");
    }
}
